//
//  ByCellPayType.m
//  chequanbao_ios
//
//  Created by pro on 17/5/16.
//  Copyright © 2017年 com.itboye. All rights reserved.
//

#import "ByCellPayType.h"

@implementation ByCellPayType
{
    UIImageView *_iconView;             // 图片
    UILabel     *_titleLabel;           // 标题
    UILabel     *_subTitleLabel;        // 子标题
    UIButton    *_selectBtn;            // 选中视图
    UILabel     *_line;                 // 线条
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
    // 主图
    _iconView = [[UIImageView alloc] init];
    [self.contentView addSubview:_iconView];
    
    // 标题
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.numberOfLines = 2;
    _titleLabel.font = FONT(16);
    _titleLabel.textColor = TEXT_COLOR;
    _titleLabel.textAlignment = NSTextAlignmentLeft;
    [self.contentView addSubview:_titleLabel];
    
    // 选中视图
    _selectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_selectBtn setImage:[UIImage imageNamed:@"Pay_unselected"] forState:UIControlStateNormal];
    [_selectBtn setImage:[UIImage imageNamed:@"Pay_selected"] forState:UIControlStateSelected];
    [self.contentView addSubview:_selectBtn];
    _selectBtn.userInteractionEnabled = NO;
    
    // 线
    _line = [[UILabel alloc] init];
    _line.backgroundColor = ZJ_SEPLINE_COLOR;
    [self.contentView addSubview:_line];
}

- (void)setInfoDic:(NSDictionary *)infoDic {
    
    _infoDic = infoDic;
    
    [self setNeedsLayout];
}

- (void)setSelect:(BOOL)select {
    
    _select = select;
    _selectBtn.selected = _select;
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    _selectBtn.frame    = CGRectMake(0, 0, 20, 20);
    _selectBtn.left     = 10;
    _selectBtn.y        = self.height / 2;
    
    _iconView.frame     = CGRectMake(0, 0, 35, 35);
    _iconView.left      = _selectBtn.right + 10;
    _iconView.y         = self.height / 2;
    
    _titleLabel.frame   = CGRectMake(0, 0, 200, 20);
    _titleLabel.left    = _iconView.right + 10;
    _titleLabel.y       = self.height / 2;
    
    
    _line.frame         = CGRectMake(0, 0, self.width, 0.5);
    _line.bottom        = self.height;
    
    // 设置数据
    _titleLabel.text    = _infoDic[@"title"];
    _iconView.image = [UIImage imageNamed:_infoDic[@"icon"]];
    
}


@end
